﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WordAddIn2010
{
    public class CategoryInfo
    {
        List<ItemInfo> LstItem;

        public CategoryInfo()
        {
            LstItem = new List<ItemInfo>();
        }
        public List<ItemInfo> MenuItems
        {
            get
            {
                return LstItem;
            }
        }
        public void AddItem(string _name)
        {
            string[] ArrName = _name.Split('_');
            if (ArrName.Length != 2)
            {
                return;
            }
            ItemInfo itemInfo = GetItemInfo(ArrName[0]);
            itemInfo.AddItem(ArrName[1]);
        }
        private ItemInfo GetItemInfo(string _name)
        {
            for (int idx = 0; idx < LstItem.Count;idx++ )
            {
                if (LstItem[idx].category == _name)
                {
                    return LstItem[idx];
                }
            }
            LstItem.Add(new ItemInfo(_name));
            return LstItem[LstItem.Count-1];
        }
    }
}
